<!DOCTYPE html>
<html>
<head>
    <title>Physics Waveform</title>
</head>
<body>

<canvas id="physicsCanvas" width="500" height="350"></canvas>

<script>
    const canvas = document.getElementById('physicsCanvas');
    const ctx = canvas.getContext('2d');

    // Style settings
    ctx.strokeStyle = 'black';
    ctx.fillStyle = 'black';
    ctx.lineWidth = 2;
    ctx.lineCap = 'round';

    // Coordinates and dimensions
    const y_axis = 120;
    const pulse_width_px = 180;
    const pulse_height_px = 100;
    const center_x = canvas.width / 2;
    const x_start = center_x - pulse_width_px / 2;
    const x_end = center_x + pulse_width_px / 2;
    const x_peak = center_x;
    const y_peak = y_axis + pulse_height_px;

    // 1. Draw time axis
    ctx.beginPath();
    ctx.moveTo(30, y_axis);
    ctx.lineTo(canvas.width - 30, y_axis);
    ctx.stroke();
    // Arrowhead for time axis
    ctx.beginPath();
    ctx.moveTo(canvas.width - 30, y_axis);
    ctx.lineTo(canvas.width - 40, y_axis - 5);
    ctx.moveTo(canvas.width - 30, y_axis);
    ctx.lineTo(canvas.width - 40, y_axis + 5);
    ctx.stroke();
    // 't' label
    ctx.font = "italic 20px 'Times New Roman'";
    ctx.textAlign = "left";
    ctx.fillText("t", canvas.width - 25, y_axis + 8);

    // 2. Draw triangular pulse
    ctx.beginPath();
    ctx.moveTo(x_start, y_axis);
    ctx.lineTo(x_peak, y_peak);
    ctx.lineTo(x_end, y_axis);
    ctx.stroke();

    // 3. Draw '20 ns' annotation
    const y_dim_20ns = y_axis - 30;
    ctx.beginPath();
    // Dimension line
    ctx.moveTo(x_start, y_dim_20ns);
    ctx.lineTo(x_end, y_dim_20ns);
    // Left T-bar end line
    ctx.moveTo(x_start, y_dim_20ns - 6);
    ctx.lineTo(x_start, y_axis);
    // Right T-bar end line
    ctx.moveTo(x_end, y_dim_20ns - 6);
    ctx.lineTo(x_end, y_axis);
    ctx.stroke();
    // Text label
    ctx.font = "18px Arial";
    ctx.textAlign = "center";
    ctx.fillText("20 ns", center_x, y_dim_20ns - 8);

    // 4. Draw 'I_max' annotation
    const x_dim_I = x_start - 70;
    
    // Dashed line indicating the minimum level.
    // In the original, it starts from the left and connects to the peak.
    ctx.beginPath();
    ctx.setLineDash([6, 4]);
    ctx.moveTo(x_dim_I - 30, y_peak);
    ctx.lineTo(x_peak, y_peak);
    ctx.stroke();
    ctx.setLineDash([]);

    // Vertical dimension line
    ctx.beginPath();
    ctx.moveTo(x_dim_I, y_axis);
    ctx.lineTo(x_dim_I, y_peak);
    // Top arrow
    ctx.moveTo(x_dim_I - 5, y_axis + 6);
    ctx.lineTo(x_dim_I, y_axis);
    ctx.lineTo(x_dim_I + 5, y_axis + 6);
    // Bottom arrow
    ctx.moveTo(x_dim_I - 5, y_peak - 6);
    ctx.lineTo(x_dim_I, y_peak);
    ctx.lineTo(x_dim_I + 5, y_peak - 6);
    ctx.stroke();
    
    // Text label 'I_max'
    ctx.textAlign = "left";
    ctx.textBaseline = "middle";
    // 'I'
    ctx.font = "italic 20px 'Times New Roman'";
    const I_metrics = ctx.measureText("I");
    ctx.fillText("I", x_dim_I + 10, y_peak - pulse_height_px / 2);
    // 'max' subscript
    ctx.font = "14px 'Times New Roman'";
    ctx.fillText("max", x_dim_I + 10 + I_metrics.width - 2, y_peak - pulse_height_px / 2 + 6);

    // 5. Draw Figure Caption
    ctx.font = "18px Arial";
    ctx.textAlign = "center";
    ctx.textBaseline = "alphabetic"; // Reset baseline
    ctx.fillText("Fig. 3.6", center_x, canvas.height - 20);

</script>

</body>
</html>